﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;

namespace Lumberjack
{
    public static class Validation
    {

        public static void OnlyNumbers(KeyEventArgs e, TextBox textBox)
        {
            if ((e.Key < Key.D0 || e.Key > Key.D9) && (e.Key < Key.NumPad0 || e.Key > Key.NumPad9))
            {
                e.Handled = true;
            }
        }

        public static void OnlyNumbersAndCommas(KeyEventArgs e, TextBox tb)
        {
            //validate input for numbers and decimanl pointer only
            if (e.Key != Key.Decimal && e.Key != Key.OemComma && (e.Key < Key.D0 || e.Key > Key.D9) && (e.Key < Key.NumPad0 || e.Key > Key.NumPad9))
            {
                e.Handled = true;
            }
        }

        public static bool ExistsNullOrEmpty(this List<string> values)
        {
            foreach(var v in values)
            {
                if(string.IsNullOrEmpty(v))
                {
                    return true;
                }
            }
            return false;
        }
    }
}
